package com.action;

import com.orm.WebServiceEntity;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by lirance on 16/4/24.
 */
public class getAllClusters extends BaseAction {
    List<Integer> serviceId;
    List<Integer> serviceclusteName;
    List<Double> serviceRtt;
    List<WebServiceEntity> serviceList;

    public List<Integer> getServiceId() {
        return serviceId;
    }

    public void setServiceId(List<Integer> serviceId) {
        this.serviceId = serviceId;
    }

    public List<Integer> getServiceclusteName() {
        return serviceclusteName;
    }

    public void setServiceclusteName(List<Integer> serviceclusteName) {
        this.serviceclusteName = serviceclusteName;
    }

    public List<Double> getServiceRtt() {
        return serviceRtt;
    }

    public void setServiceRtt(List<Double> serviceRtt) {
        this.serviceRtt = serviceRtt;
    }

    public List<WebServiceEntity> getServiceList() {
        return serviceList;
    }

    public void setServiceList(List<WebServiceEntity> serviceList) {
        this.serviceList = serviceList;
    }

    @Override
    public String execute() throws Exception {
        this.setServiceList((List) this.getAllService().getGetServicesService().getAllEntities());
        this.setServiceclusteName(new ArrayList<>());
        this.setServiceId(new ArrayList<>());
        this.setServiceRtt(new ArrayList<>());

        for (int i = 0; i < serviceList.size(); i++) {
            serviceId.add(serviceList.get(i).getWsId());
            serviceclusteName.add(Integer.parseInt((serviceList.get(i).getClusteNam()).substring(7)));
            serviceRtt.add(Double.parseDouble((serviceList.get(i).getClusteNum()).substring(0,6)));
        }
        return SUCCESS;
    }
}
